package com.wc.alorithm_luogu.P3613;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;
import java.util.ArrayList;
import java.util.HashMap;

/**
 * @Author congge
 * @Date 2023/5/14 17:35
 * @description https://www.luogu.com.cn/problem/P3613
 * 寄包柜
 */
public class Main {
    public static void main(String[] args) {
        Input sc = new Input();
        int n = sc.nextInt();
        int q = sc.nextInt();

        // 运用HashMap提速
        ArrayList<HashMap<Integer, Integer>> arrayList = new ArrayList<>();

        for (int i = 0; i < n; i++) {
            arrayList.add(new HashMap<>());
        }

        // 操作
        int operator;
        // 柜子
        int cabinet;
        // 格子
        int lattice;
        StringBuilder ans = new StringBuilder();

        for (int i = 0; i < q; i++) {
            operator = sc.nextInt();
            cabinet = sc.nextInt();
            lattice = sc.nextInt();
            HashMap<Integer, Integer> bucket = arrayList.get(cabinet - 1);

            Integer thing = bucket.get(lattice);

            if (operator == 1) {
                bucket.put(lattice, sc.nextInt());
            } else {
                ans.append(thing);
                ans.append('\n');
            }
        }

        System.out.print(ans);
    }

    static class Input {
        StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));

        public int nextInt() {
            try {
                in.nextToken();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return (int) in.nval;
        }
    }
}
